<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
	<head>
		<title>_菜鸟面单设计</title>
		<script type="text/javascript">
			function valNumber(tempNumber){
		
		  var rex_one="^[1-9]+(.[0-9]{0,2})?$";
		  var result_one =tempNumber.match(rex_one);
		  if(result_one==null){
		    return false;
		  }
	   	   return true;
		}
	function widthHeight() {
		var tempWidth = "${expressStyle.remarks}";
		var tempString = tempWidth.split("*");
		for ( var i = 0; i < tempString.length; i++) {
			if (i == 0) {
				var width = tempString[i];
			
				width=width/100;
				$("#expressWidth").val(width);
			} else if (i == 1) {
				var height = tempString[i];
				height=height/100;
				$("#expressHeight").val(height);
			}
		}
	}
</script>
	</head>
	<body>
	<section class="content">
	<div class="row">
		<div class="col-md-12">
		<div class="box box-solid box-primary">
					<div class="box-header">

						<h3 class="box-title">${titlePage}</h3>
						<div class="box-tools pull-right">
							<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
								<i class="fa fa-minus"></i>
							</button>
						</div>
					</div>
					<div class="box-body">
		<div class="alert alert-success" id="message" style="display: none;">
			<button data-dismiss="alert" class="close">
				×
			</button>
			<span id="content">修改成功</span>
		</div>
		<fieldset>
		<div class="form-group row">
			<div class="col-sm-3">
			<div class="input-group">
				<input type="hidden" value="${expressStyle.id}" id="expressStyleId">
				<label for="pmsprinters_corpLevel" class="input-group-text">
					快递:
				</label>
				<input type="text" id="logisticsCompanyName"
					name="logisticsCompanyName"
					value="${expressStyle.logisticsCompany.companyName}"
					class="form-control input-large required" minlength="3" readOnly="true" />
			</div>
			</div>
			
			<div class="col-sm-3">
			<div class="input-group">
				<label for="pmsprinters_corpLevel" class="input-group-text">
					快递单名称:
				</label>
				<input type="text" id="expressStyleName" name="expressStyleName"
					value="${expressStyle.styleName}" class="form-control input-large required"
					minlength="3" />
				
			</div>
			</div>
			<script type="text/javascript">
			var defineParam = [];
			var CaiNiaoDesign ;
	jQuery(document).ready(
			function() {
			initCNDesign();
			var boxes = $("input[type='checkbox']",$("#selectNames"));
					    boxes.on("ifChanged", function(event){
							Moditify($(this));
						});
				jQuery("#button_btn")
						.click(
								function() {
									var content = getCaiNiaoDesignContent();
									var expressStyleName = $(
											"#expressStyleName").val();
									var checkDefault = "mail";
									
									var expressWidth = $("#expressWidth").val();
		var expressHeight = $("#expressHeight").val();
		if (!valNumber(expressWidth)) {
			alert("请填入正确的长度");
			$("#expressWidth").focus();
			return;
		} else {
			expressWidth = expressWidth * 100;
		}
		if (!valNumber(expressHeight)) {
			alert("请填入正确的宽度");
			$("#expressHeight").focus();
			return;
		} else {
			expressHeight = expressHeight * 100;
		}
									var temp = '&content=' + content
											+ '&expressStyleName='
											+ expressStyleName
											+ '&type=' + checkDefault+'&expressWidth='+expressWidth+'&expressHeight='+expressHeight
											+'&cainiaoFlg=1'
											+'&defineParam='
											+defineParam.join(";");
									updateAjaxExpressStyle(temp);
								});
			selectAjaxDesign();
			});
	function updateAjaxExpressStyle(ajaxTempString) {
		
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressPrinting/updateAjaxExpressStyle',
			data : 'expressStyleId=' + $("#expressStyleId").val()
					+ ajaxTempString,
			dataType : 'json',
			success : function(data) {
				    $("#content").html(data.content);
					$("#message").show();
				
			},
			error : function() {

			}
		});
	}
	function selectAjaxDesign() {
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressPrinting/selectAjaxDesign',
			data : 'expressStyleId=' + '${expressStyle.id}',
			dataType : 'json',
			success : function(data) {
				if (data.status="1") {
					CNcheckedData();
					CNDisplayDesign("${expressStyle.logisticsCompany.companyCode}","${expressStyle.styleContent}");
				}
			},
			error : function() {

			}
		});
	}
	function CNcheckedData(){
		var contents = "${expressStyle.defineParam}".split(";");
		$.each(contents,function(i,e){
			$("input[name='" + e + "']").iCheck('check');
			CaiNiaoDesign.SET_PRINT_STYLEA(e, 'Deleted', true);
		});
	}

</script>
	</div>
			
		</fieldset>
			<tags:printerLodop></tags:printerLodop>
			<div class="modal-footer bg-gray">
				<c:if test="${status eq 0 }">
					<input id="button_btn" class="btn btn-success" type="button"
						value="增加" />
				</c:if>
				<c:if test="${status eq 1 }">
					<input id="button_btn" class="btn btn-info" type="button"
						value="修改" />
				</c:if>
				&nbsp;
				<input id="cancel_btn" class="btn" type="button" value="返回"
					onclick="history.back()" />
		</div>
		</div>
		</div>
		</div>
		</div>
		</section>
	</body>
</html>
